<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8" />
		<title>流程列表</title>
		<div th:replace="common/common_grid_header"></div>
		<script type="text/javascript">

			$(function () {
				var params = {
					searchParams:{
						userId:"kermit"
					}
				};
			    var url = "/process/task/list/data";
			    $("#dg").datagrid({
				    method:'post',
				    url:url,
				   	autoRowHeight:false,
				   	fit:true,
				   	remoteSort:true,
				   	border:false,
				   	rownumbers: true,
				   	pagination:true,
				   	fitColumns:true,
				   	singleSelect:true,
				   	multiSort:true,
				   	pageSize:15,
				   	pageList:[15,30,50,100],
				   	queryParams:params,
				   	onBeforeLoad : function(param){
				   		var size = param.rows; //保存下值
				   		delete param.rows; //删掉
				   		param.size = size; //重新命名
				   	},
				   	columns:[[ 
						{field:'id',title:'taskId',width:80},
			            {field:'name',title:'name',width:150,sortable:true},
			            {field:'assignee',title:'assignee',width:100},
						{field:'formKey',title:'formKey',width:60,sortable:true},
						{field:'description',title:'description',width:60,sortable:true},
						{field:'createTime',title:'createTime',width:120,sortable:true},
						{field:'action',title:'操作',width:80,formatter:fmtAction,align:'center'}
				    ]]
			    });
			});
			
			function fmtAction(v,r){
				return "<a href=javascript:runProcess('"+r.id+"') >审批<a/>";
			}
			
			function runProcess(taskId){
				//layer.confirm('确定执行流转吗？', function(index){
		        	$.post("/process/task/complete",{taskId:taskId},function(res){
			        	//layer.close(index);
			        	alert(res.message);
			        	$("#dg").datagrid("reload");
		            },"json");
		      	//});
			}
			
			
		</script>
	</head>
	<body>
		<table id="dg" ></table>
	</body>
</html>